package fr.insee.sicape.bean;

public class Apet implements Comparable<Apet>{

	private String code;
	private int pourcentage;
	
	public Apet() {
		super();
	}

	public Apet(String code, int pourcentage) {
		super();
		this.code = code;
		this.pourcentage = pourcentage;
	}

	public String getCode() {
		return code;
	}
	
	public void setCode(String code) {
		this.code = code;
	}
	
	public int getPourcentage() {
		return pourcentage;
	}
	
	public void setPourcentage(int pourcentage) {
		this.pourcentage = pourcentage;
	}
	
	@Override
	public int compareTo(Apet other) {
		
		if(this.pourcentage == other.pourcentage){
			return 0;
		}
		else if(this.pourcentage > other.pourcentage){
			return 1;
		}
		else{
			return -1;
		}
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((code == null) ? 0 : code.hashCode());
		result = prime * result + pourcentage;
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Apet other = (Apet) obj;
		if (code == null) {
			if (other.code != null)
				return false;
		} else if (!code.equals(other.code))
			return false;
		if (pourcentage != other.pourcentage)
			return false;
		return true;
	}
}
